<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8" isELIgnored="false"%>
<%@include file="/resources/common/commonTaglibs.jsp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<!-- 导入资源文件 -->
<%@include file="/resources/common/commonJs.jsp" %>
<%@include file="/resources/common/commonCss.jsp" %>
<title>校车预约列表</title>
<script type="text/javascript">
function toAdd() {
	window.location.href = '${path}/busBespeak/toBusBespeakPage';
}

//删除
function recordDel(id) {
	top.layer.confirm('确定要删除选择的预约记录吗？', function(index) {
		var url = '${path}/busBespeak/busBespeakDel/'+id;
		alert(url)
		$.post(url, {}, function(data) {
			if (data.status == 'success') {
				top.layer.close(index);
				top.layer.alert('预约记录删除成功!');
				window.location.href = '${path}/busBespeak/busBespeakList';
			} else if (data.status == 'error') {
				top.layer.close(index);
				top.layer.alert('预约记录删除失败!');
			}
		}, 'json');
	});
}
//预约详情
function detail(id) {
	window.location.href = '${path}/busBespeak/busBespeakDetails/'+id;
}

$(function() {
	//全选/全不选
	$('#quanxuan').click(function() {
		var checkStatus = $(this).attr('checked');
		var $quanxuan = $('input[name="quanxuan"]');
		if (checkStatus) {
			$quanxuan.attr('checked', true);
		} else {
			$quanxuan.attr('checked', false);
		}
	});
})
</script>
</head>
<body>
<body style="margin: 5px 5px;">
<!-- 条件参数查询start -->
<form action="${path }/busBespeak/busBespeakList" method="post" id="searchForm">
	<input type="hidden" name="pageNumber" value="${number }"/>
	<input type="hidden" name="pageSize" value="${size }"/>
	<!-- 实体对象查询参数 -->
	<table style="margin-top: 20px;margin-bottom: 25px; width: 100%">
		<tbody>
		<tr>
			<td>姓名</td>
			<td><input type="text" name="projectUser.name" value="${bespeakRecord.projectUser.name }" class="form-control"/></td>
			<td>始发站</td>
			<td>
				<select class="form-control" name="busSchedule.startStation">
					<option value="-1">请选择</option>
					<option value="1" <c:if test="${bespeakRecord.busSchedule.startStation == 1 }">selected</c:if>>金花校区</option>
					<option value="2" <c:if test="${bespeakRecord.busSchedule.startStation == 2 }">selected</c:if>>临潼校区</option>
				</select>
			</td>
			<td>工号</td>
			<td><input type="text" name="projectUser.userNo" value="${bespeakRecord.projectUser.userNo }" class="form-control"/></td>
			<td>
				<button class="btn btn-primary" onclick="searchSiteList()">查询</button>
				<button class="btn resetBtn">重置</button>
			</td>
		</tr>
		</tbody>
	</table>
</form>
<!-- 条件参数查询end -->
<!-- 其他操作按钮start -->
<div>
	<!-- <button onclick="toAdd()" class="btn btn-primary">添加预约记录</button> -->
	<!-- <button onclick="batchDel()" class="btn btn-primary">批量删除</button> -->
</div>
<!-- 其他操作按钮end -->
<!-- 数据列表的显示start -->
<div class="listDataTableStyle">
	<table cellpadding="0" cellspacing="0" width="100%">
		<thead>
		<tr>
			<th><input type="checkbox" id="quanxuan"/></th>
			<th>序号</th>
			<th>预约教师姓名</th>
			<th>预约教师编号</th>
			<th>预约车次</th>
			<th>始发站</th>
			<th>终点站</th>
			<th>发车时间</th>
			<th>到达时间</th>
			<th>申请时间</th>
			<th>当前状态</th>
			<th>操作</th>
		</tr>
		</thead>
		<tbody>
		<c:if test="${empty page.content }">
			<tr><td colspan="11">没有教师预约信息</td></tr>
		</c:if>
		<c:if test="${!empty page.content }">
		<c:forEach items="${page.content }" var="data" varStatus="index">
		<tr>
			<td><input type="checkbox" name="quanxuan"/><input type="hidden" value="${data.id }"/></td>
			<td>${index.index + 1}</td>
			<td>${data.projectUser.name }</td>
			<td>${data.projectUser.userNo }</td>
			<td>${data.busSchedule.scheduleNo }</td>
			<td>${data.busSchedule.startStation == 1 ? '金花校区' : '临潼校区' }</td>
			<td>${data.busSchedule.endStation == 1 ? '金花校区' : '临潼校区' }</td>
			<td>${data.busSchedule.startTime }</td>
			<td>${data.busSchedule.endTime }</td>
			<td><fmt:formatDate value="${data.applyTime }" pattern="yyyy-MM-dd"/></td>
			<td>${data.status == 1 ? '已预定' : (data.status == 2 ? '预约成功' : '未知') }</td>
			<td>
				<a href="javascript:;" class="icon-minus-sign" onclick="recordDel('${data.id}')">删除</a>&nbsp;
				<%-- <a href="javascript:;" class="icon-info-sign" onclick="detail('${data.id}')">查看</a> --%>
			</td>
		</tr>
		</c:forEach>
		</c:if>
		</tbody>
	</table>
</div>
<!-- 数据列表的显示end -->
<!-- 分页start -->	
<table width="100%">
	<tr>
		<td width="20%">
			<div class="pagin" style="margin-top: 0px !important;">
				<div style="font-size: 14px; font-family: Helvetica Neue,Helvetica,Arial,sans-serif">共<i style="color: blue;">${page.totalElements }</i>条记录，当前第&nbsp;<i style="color: blue;">${page.number+1 }&nbsp;</i>页</div>
			</div>
		</td>
		<td>	
			<div id="Pagination" class="pagination" style="float:right;margin-right:20px;">
			<script type="text/javascript">
					$(document).ready(function(){
						//获取起始页	 
					  	$("#Pagination").pagination(${page.totalElements}, {//总页数
						  num_edge_entries : 2,//分页页码段右的页码个数
						  num_display_entries : 5,//分页页码段右的页码个数
						  callback : pageselectCallback,//回调函数
						  current_page : ${page.number},//当前页
						  items_per_page :${page.size}//每页多少条
					  	});
					});
					
					//分页回调函数
					function pageselectCallback(start, jq){
						$('#pageNumber').val(start);
						search(false);
					}
					//查询方法
				    function search(resetPageNum){
				    	if(resetPageNum){
					        $('#pageNumber').val(0);//重置分页参数,由于分页时也调用此方法，所以增加判断
						}
				        $('#searchForm').submit();
				    }
				    //重置
				    function resetSform(){
						location.href = '#';
				    } 
				</script>
		    </div>
		</td> 
	</tr>
</table>
<!-- 分页end -->
</body>
</html>